#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

#define LEN 99

int hosts_remove()
{
  FILE *cpf1, *cpf2;
  char len[LEN+1];

  cpf1 = fopen( "/etc/hosts.basic", "r");
  if(cpf1 == (FILE *)NULL)
  {
      fprintf( stderr, "文件读取失败\n");
      return(-1);
  }

  cpf2 = fopen( "/etc/hosts", "w");
  if(cpf2 == (FILE *)NULL)
  {
      fprintf( stderr, "文件以写入方式打开失败\n");
      return(-1);
  }

  while((fgets( len, LEN, cpf1)) != NULL)
  {
      fputs( len, cpf2 );
  }

  fclose(cpf2);
  fclose(cpf1);

  remove("/tmp/gipv6");

  return(0);
}
